package com.goblin.model.film.controller;

import com.goblin.common.response.PageHelper;
import com.goblin.common.response.Paged;
import com.goblin.common.response.Response;
import com.goblin.model.base.BaseController;
import com.goblin.model.film.po.Film;
import com.goblin.model.film.service.FilmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/v1/film/film")
public class FilmController extends BaseController<Film> {

	@Autowired
	private FilmService filmService;

	@GetMapping("/films")
	public Response<Paged<Film>> paged(PageHelper pageable) {
		Paged<Film> entities = this.filmService.paged(pageable);
		return Response.success(entities);
	}

	/**
	 * @param time 启动时长，单位分钟， 默认60分钟
	 * @desc: 启动搜索.
	 * @author goblin
	 * @date 2021/1/5 9:52
	 */
	@GetMapping("/doSearch")
	public Response<Paged<Film>> searchFilm(
			@RequestParam(required = false, defaultValue = "60") Integer time) {
		this.filmService.searchFilm(time);
		return Response.success();
	}

}
